<?php
// 查询所有数据返回给前端
// 连接数据库
$conn = mysqli_connect('localhost', 'root', 'root', 'newdata');

// 设置编码
mysqli_query($conn, "set charset 'utf8'");
mysqli_query($conn, "set character set 'utf8'");

// sql语句
$sql = "select * from info order by id";
// 执行   返回资源类型数据
$res = mysqli_query($conn,$sql);

$list = array();
// 从$res里一行一行取数据
while($row = mysqli_fetch_assoc($res)){
	// 把每行数据放入$list数组里
	array_push($list, $row);
}

echo json_encode(array(
	"code" => 200,
	"body" => array(
		"list" => $list
	)
));


?>